<template>
  <el-container class="app-container" v-loading="loading">
    <el-header style="height: auto">
      <el-form
        ref="form"
        :model="queryform"
        :inline="true"
        label-width="80px"
        size="small "
        class="search-form-inline"
      >
         <el-form-item label="案件接警号:" label-width="120px">
          <el-input v-model="queryform.jNum" placeholder="请输入" />
        </el-form-item>
        <!-- <el-form-item label="涉案人姓名:" label-width="120px">
          <el-input v-model="queryform.ip" placeholder="请输入" />
        </el-form-item> -->

        <el-form-item label="涉案人身份证:" label-width="120px">
          <el-input v-model="queryform.sfzh" placeholder="请输入" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handlequery"
            >查 询</el-button
          >
        </el-form-item>
        <el-form-item  style="float:right;">
          <el-button @click="handleBathDelete" type="primary">{{multipleSelection.length}}条记录批量删除</el-button>
          <el-button @click="handleUpload" type="primary">导入</el-button>
        </el-form-item>
      </el-form>
    </el-header>
    <el-main class="main-data-table">
      <DynamicTable :columns="tableColumns" :list="tableData" :current-page="currentPage" ref="singleTable" @selection-change="handleSelectionChange">
        <template slot="top">
          <el-table-column type="selection" width="55" > </el-table-column>
        </template>
        <template slot="end">
          <el-table-column fixed="right" label="操作" width="200">
            <template slot-scope="scope">
              <el-row>
                <el-button type="text" size="small" @click="handleEdit(scope.row)">修改</el-button>
                <span class="vertical">|</span>
                <el-button type="text" size="small" @click="handleDelete(scope.row)">删除</el-button>
              </el-row>
            </template>
          </el-table-column>
        </template>
      </DynamicTable>
    </el-main>
    <el-footer>
      <div class="pagination">
        <CustomPage
          :currentPage="currentPage"
          :pageSize="pageSize"
          :total="total"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        />
      </div>
    </el-footer>
    <UploadDialog ref="upload" :uploadUrl="uploadUrl" :params="uploadParams" @uploaded="()=>{loadData()}"> </UploadDialog>
    <el-dialog
            title="图像队列修改"
            :visible.sync="dialogVisible"
            :append-to-body="true"
            width="1000px"
            :close-on-click-modal="false"
            center
    >
      <DynamicForm
              ref="form"
              :columns="formColumn"
              :label-width="labelWidth"
              :key="dialogVisible"
              :data="formData"
      >
      </DynamicForm>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
        <el-button @click="save" type="primary">确 定</el-button>
      </span>
    </el-dialog>
  </el-container>
</template>

<script>
import CustomPage from '@/common/CustomPageMin';
import CuPopover from '@/common/CuPopover';
import UploadDialog from '@/common/UploadDialog';
import DynamicTable from '@/common/DynamicTable';
import DynamicForm from '@/common/DynamicForm';
import PublicMethod from '@/lib/public-method';

export default {
  components: {
    CustomPage,
    CuPopover,
    UploadDialog,
    DynamicTable,
    DynamicForm,
  },
  data() {
    return {
      loading: false,
      dialogVisible: false,
      formData: {},
      formColumn: [],
      labelWidth: '160px',
      uploadParams: {
        type: '图像'
      },
      queryform: {
        jNum: '',
        sfzh: '',
        type: '图像',
        status: '0',
      },
      dataType: [{
        dictValue: '',
        dictLabel: ''
      }],
      multipleSelection: [],
      uploadUrl: '/clueQueue/import',
      currentPage: 1,
      pageSize: 10,
      total: 0,
      tableData: [],
      tableColumns: [
        {
          field: 'jinId',
          title: '案件接警号',
          readonly: true,
          width: '120px',
        },
        {
          field: 'sfzh',
          title: '身份证号',
          width: '120px',
        },
      ],
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.loadData();
    });
  },
  methods: {
    handleUpload() {
      this.$refs['upload'].show();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handlequery() {
      this.currentPage = 1;
      this.loadData();
    },
    handleSizeChange(size) {
      this.currentPage = 1;
      this.pageSize = size;
      this.loadData();
    },
    handleCurrentChange(page) {
      this.currentPage = page;
      this.loadData();
    },
    ...PublicMethod('clueQueue')
  },
  filters: {
    StrToDate(str) {
      if (str) {
        var nstr =
          str.substr(0, 4) +
          '-' +
          str.substr(4, 2) +
          '-' +
          str.substr(6, 2) +
          ' ' +
          str.substr(8, 2) +
          ':' +
          str.substr(10, 2) +
          ':' +
          str.substr(12, 2);
        return nstr;
      } else {
        return '-';
      }
    },
  },
};
</script>

<style lang="less" scoped></style>
